package com.ruoyi.api.kehu.pay;


import com.ruoyi.system.service.ApiPayNotifyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.text.ParseException;
import java.util.Map;


@RestController
@RequestMapping("/api/paynotify")
public class ApiPayNotifyController {


     @Autowired
     private  ApiPayNotifyService apiPayNotifyService;

    /**
     * 微信小程序项目支付回调接口
     */
    @PostMapping("/wxItemPayNotice")
    public Map<String, String> wxItemPayNotice(@RequestBody String xmlData) throws ParseException {
        return  apiPayNotifyService.wxItemPayNotice(xmlData);
    }


    /**
     * 微信小程序商城支付回调接口
     */
    @PostMapping("/wxMallPayNotice")
    public Map<String, String> wxMallPayNotice(@RequestBody String xmlData) throws ParseException {
        return apiPayNotifyService.wxMallPayNotice(xmlData);
    }


    /**
     * 微信小程序代理支付回调接口
     */
    @PostMapping("/wxProxyPayNotice")
    public Map<String, String> wxProxyPayNotice(@RequestBody String xmlData) throws ParseException {
        return apiPayNotifyService.wxProxyPayNotice(xmlData);
    }



    /**
     * 退款通知
     */
    @RequestMapping(value = "/refundNotify", method = {RequestMethod.POST, RequestMethod.GET})
    @ResponseBody
    public String refundNotify(HttpServletRequest request) {
        return  apiPayNotifyService.refundNotify(request);
    }

    @RequestMapping(value = "/mallRefundNotify", method = {RequestMethod.POST, RequestMethod.GET})
    @ResponseBody
    public String mallRefundNotify(HttpServletRequest request) {
        return  apiPayNotifyService.mallRefundNotify(request);
    }
    /**
     * 微信小程序充值回调接口
     */
    @PostMapping("/wxmallPayChongZhiNotice")
    public Map<String, String> wxmallPayChongZhiNotice(@RequestBody String xmlData) throws ParseException {
        return  apiPayNotifyService.wxmallPayChongZhiNotice(xmlData);
    }


    /**
     * 微信支付回调接口
     */
    @PostMapping("/wxPayNotice")
    public Map<String, String> wxPayNotice(@RequestBody String xmlData) throws ParseException {
       return apiPayNotifyService.wxPayNotice(xmlData);
    }

    /**
     * 退款通知
     */
    @RequestMapping(value = "/wxRefundNotify", method = {RequestMethod.POST, RequestMethod.GET})
    @ResponseBody
    public String wxRefundNotify(HttpServletRequest request) {
        return apiPayNotifyService.wxRefundNotify(request);
    }

    /**
     * 微信充值回调接口
     */
    @PostMapping("/wxPayChongZhiNotice")
    public Map<String, String> wxPayChongZhiNotice(@RequestBody String xmlData) throws ParseException {
        return apiPayNotifyService.wxPayChongZhiNotice(xmlData);
    }


    //alipay异步通知调用地址 支付宝支付订单回调
    @PostMapping("/aliAppPayNotify")
    @Transactional
    public String aliAppPayNotify(HttpServletRequest request) throws Exception{
        return apiPayNotifyService.aliAppPayNotify(request);
    }


    //alipay异步通知调用地址 支付宝充值回调
    @PostMapping("/aliAppPayChongZhiNotify")
    @Transactional
    public String aliAppPayChongZhiNotify(HttpServletRequest request) throws Exception{
        return apiPayNotifyService.aliAppPayChongZhiNotify(request);

    }


    @PostMapping("/batchTransferNotice")
    @Transactional
    public String batchTransferNotice(HttpServletRequest request) throws Exception{

        return apiPayNotifyService.batchTransferNotice(request);

    }


}